<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript" src="<%= request.getContextPath() %>/js/jquery-2.1.4.min.js"></script>

<script type="text/javascript">
	$(function(){
		$(".delete").click(function(){
			var url = $(this).attr("href");
			var args = {"_method":"delete"};
			$.post(url,args)
			window.location.reload();
			return false;
		})
	})
</script>

</head>
<body>
	<h3>Employee List Page</h3>


	<c:if test="${empty requestScope.employees }">
		没有员工信息！
	</c:if>
	
	<c:if test="${!empty requestScope.employees }">
		<table cellpadding="10" border="1">
			<thead>
				<tr>
					<td>ID</td>
					<td>LastName</td>
					<td>Email</td>
					<td>Gender</td>
					<td>Department</td>
					<td>Delete</td>
					<td>Edit</td>
				</tr>
			</thead>
			
			<c:forEach items="${requestScope.employees }" var="emp">
			<tbody>
				<tr>
					<td>${emp.id }</td>
					<td>${emp.lastName }</td>
					<td>${emp.email }</td>
					<td>${emp.gerder == 0 ? '男' : '女' }</td>
					<td>${emp.department.id }-${emp.department.departmentName }</td>
					<td><a href="<%= request.getContextPath() %>/employee/emp/${emp.id }" class="delete">Delete</a></td>
					<td><a href="<%= request.getContextPath() %>/employee/emp/${emp.id }">Edit</a></td>
				</tr>
			</tbody>
			</c:forEach>
			
		</table>
	</c:if>
	<br>
	<a href="<%= request.getContextPath() %>/employee/emp">Employee Input</a>
</body>
</html>